package com.tai.network;

import org.junit.Test;

import java.io.*;

/**
 * The type Buffer stream demo.
 *
 * @author taylor
 * @Description: 缓冲流
 * @date 2021 /6/22 21:30
 */
public class BufferStreamDemo {

    /**
     * Buffer stream test.
     */
    @Test
    public void bufferStreamTest(){
        BufferedReader br = null;
        BufferedWriter bw = null;

        try {
            br = new BufferedReader(new FileReader(new File("temp/满江红.txt")));
            bw = new BufferedWriter(new FileWriter(new File("temp/满江红-岳飞.txt")));

            String data ;
            while ((data = br.readLine()) != null){
                bw.write(data);//不包含换行符
                bw.newLine();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                br.close();
                bw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

